<?php
/////////////////////////////////////////////////////////////////////////////
// 
//
// workflow_system 
//
// workflow_copyright
// 
/////////////////////////////////////////////////////////////////////////////

/**
 * FILE_NAME : member_group.class.php
 * ....会员用户组操作类
 *
 * @copyright workflow_system 
 * @author workflow Develop Team 
 * @package 
 * @subpackage 
 * @version Tue May 26 17:35:48 CST 2009
 */

defined('Base_Use_Sign') or die("this is invalid system!please contact <a href='http://www.shopnc.net'>www.shopnc.net</>.");

class MemberGroupClass extends FrameWork {
	/**
	 * 用户组列表
	 * @author workflow Develop Team     
	 * @param  $condition 检索条件 obj_page 分页
	 * @return array
	 */
	function getMemberGroupList($condition,& $obj_page){
		$conditionstr = $this->_conditionSearch($condition);
		$group_array = $GLOBALS['db']->GetList($conditionstr, $obj_page, "member_group");
		return $group_array;
	}
	
	/**
	 * 构造检索条件
	 * @author workflow Develop Team     
	 * @param  $condition 检索条件
	 * @return string
	 */
	function _conditionSearch($condition){
		$condition_str = '';
		
		if ($condition['between'] != ''){
			$condition_str .= " and mg_score_lower <= '" . $condition['between'] . "' and mg_score_higher > '" . $condition['between'] . "'";
		}
		if ($condition['order_by'] != ''){
			$condition_str .= "order by ".$condition['order_by'];
		}
		return $condition_str;
	}
	
	/**
	 * 增加用户组
	 * @author workflow Develop Team     
	 * @param  $input 信息内容
	 * @return bool
	 */
	function addMemberGroup($input){
		if (is_array($input)){
			$value_array = array();
			foreach ($input as $k => $v){
				$value_array[$k] = $v;
			}
			$result = $GLOBALS['db']->InsertRow($value_array, 'member_group', 'mg_id');
			return $result;
		}else {
			return false;
		}
	}
	
	/**
	 * 更新
	 * @author workflow Develop Team     
	 * @param  $input 信息内容
	 * @return bool
	 */
	function updateMemberGroup($input){
		if (is_array($input)){
			$value_array = array();
			foreach ($input as $k => $v){
				$value_array[$k] = $v;
			}
			$result = $GLOBALS['db']->UpdateRow($value_array['mg_id'],$value_array, 'member_group', 'mg_id');
			return $result;
		}else {
			return false;
		}
	}
	
	/**
	 * 删除用户组
	 * @author workflow Develop Team     
	 * @param  $id 删除ID
	 * @return bool
	 */
	function delMemberGroup($id){
		if (intval($id) > 0){
			$del_rs = $GLOBALS['db']->DelRow(intval($id), 'member_group', 'mg_id');
			return $del_rs;
		}else {
			return true;
		}
	}
	
	/**
	 * 取指定ID的会员组
	 * @author workflow Develop Team     
	 * @param  $id 用户组ID
	 * @return array
	 */
	function getMemberGroupRow($id){
		if (intval($id) > 0) {
			$group_array = $GLOBALS['db']->GetOneRow($id,"member_group","mg_id");
			return $group_array;
		}else {
			return false;
		}
	}
	
}
?>